<template>
  <!-- 检查事项 -->
  <div class="dialog-container">
    <el-dialog
      title="排口日志"
      :visible="dialogVisible"
      @open="initData"
      @close="closeDialog"
    >
      <div class="table-panel">
        <el-table
          ref="table"
          class="grid-data-table"
          height="calc(100vh - 400px)"
          :data="tableData"
        >
          <el-table-column prop="content" label="操作详情" />
        </el-table>
        <div class="pagination-container">
          <Pagination
            v-show="query.total>0"
            :total="query.total"
            :page.sync="query.page"
            :limit.sync="query.limit"
            @pagination="initData"
          />
        </div>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { getPage } from '@/api/base/outletManageLog'
import Pagination from '@/components/Pagination'

export default {
  name: 'LogDialog',
  components: {
    Pagination
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    obj: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      query: {
        total: 0,
        page: 1,
        limit: 10,
        outletId: null
      },
      tableData: [],
      tableLoading: false,
      rules: {
      // examineResult: [{ required: true, message: '请选择违法行为判定', trigger: 'change' }]
      }
    }
  },
  created() {
  },
  methods: {
    initData() {
      this.handleQuery()
    },
    handleQuery() {
      if (this.obj) {
        this.tableLoading = true
        this.query.outletId = this.obj.id
        const query = JSON.parse(JSON.stringify(this.query))
        getPage(query).then(res => {
          this.tableData = res.data.rows
          this.query.total = res.data.total
          this.tableLoading = false
        }).catch(() => {
          this.tableLoading = false
        })
      }
    },
    closeDialog() {
      this.$emit('closeDialog')
      this.clearData()
    },
    clearData() {
      this.query = {
        total: 0,
        page: 1,
        limit: 10,
        outletId: null
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
